<template>
  <div class="image-validation">
    <img class="code" :src="authCodeSrc" />
    <span @click="createCode" class="create-code">换一张</span>
  </div>
</template>
<script>
export default {
  name: 'HycImageValidation',
  inheritAttrs: false,
  props: {
    imageSrc: {
      type: String,
      default: '/open/getSystemUserLoginCerificationImg',
    },
  },
  data() {
    return {
      authCodeSrc: '',
    }
  },
  created() {
    this.createCode()
  },
  methods: {
    createCode() {
      this.time = new Date().getTime()
      const authCodeApi = process.env.VUE_APP_BASE_URL_API + this.imageSrc
      this.authCodeSrc = `${authCodeApi}?uuid=${this.time}`
    },
  },
}
</script>
<style lang="scss" scoped>
.image-validation {
  display: inline-block;
}
</style>
